/*
 * @Author: cq
 * @LastEditors: cq
 * @Date: 2025-07-03 09:18:47
 * @LastEditTime: 2025-07-03 09:19:04
 * @FilePath: \droneManagementPlatform\src\utils\EventBus.js
 */
// 全局事件总线工具类
class EventBus {
    constructor() {
      this.events = {};
    }
  
    on(event, handler) {
      if (!this.events[event]) {
        this.events[event] = [];
      }
      this.events[event].push(handler);
    }
  
    off(event, handler) {
      if (!this.events[event]) return;
      this.events[event] = this.events[event].filter(h => h !== handler);
    }
  
    emit(event, ...args) {
      if (!this.events[event]) return;
      this.events[event].forEach(handler => handler(...args));
    }
  }
  
  const eventBus = new EventBus();
  export default eventBus;
  